package com.zmkj.taobao.taobaouserservice;

import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
import com.baomidou.mybatisplus.generator.config.PackageConfig;
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;

public class AutoCreateCode {

    public static void main(String[] args) {
        System.out.println(System.getProperty("user.dir"));
         // 代码生成器
         AutoGenerator mpg = new AutoGenerator();
        //全局配置
         GlobalConfig gc = new GlobalConfig();
         String projectPath = System.getProperty("user.dir")+"\\zmkj-taobao\\taobao-userservice";
         gc.setOutputDir(projectPath + "/src/main/java");//设置代码生成位置
         gc.setAuthor("wll");//作者
         gc.setOpen(true);
         mpg.setGlobalConfig(gc);
        //数据库链接配置
        DataSourceConfig dsc = new DataSourceConfig();
        dsc.setUrl("jdbc:mysql://localhost:3306/zmkj-taobao?characterEncoding=UTF-8&serverTimezone=UTC");
        dsc.setDriverName("com.mysql.cj.jdbc.Driver");
        dsc.setUsername("root");
        dsc.setPassword("2580");
        mpg.setDataSource(dsc);

        //策略配置
        StrategyConfig strategy = new StrategyConfig();
        strategy.setNaming(NamingStrategy.underline_to_camel);
        strategy.setColumnNaming(NamingStrategy.underline_to_camel);
        strategy.setInclude(new String[]{"user"});
        mpg.setStrategy(strategy);
        //包配置
        PackageConfig pc = new PackageConfig();
        pc.setParent("com.zmkj.taobao.taobaouserservice");//父包
        pc.setMapper("dao");//DAO
        pc.setService("service");
        pc.setXml("mapper");
        mpg.setPackageInfo(pc);
        //生成代码
        mpg.execute();
    }






}
